package com.mate.cloud;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.client.RestTemplate;

@SpringBootTest
class MateUserApplicationTests {

    @Test
    void contextLoads() {
    }


    @Autowired
    private RestTemplate restTemplate;

    /**
     * 流控模式之关联测试
     */
    @Test
    void writeQps() {
        try {
            for (int i = 0; i < 10000; i++) {
                String result = restTemplate.getForObject("http://localhost:8081/user/write", String.class);
                System.out.println("writeQps#result:" + result);
                Thread.sleep(300);

            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * 流控模式之关联测试
     */
    @Test
    void writeQpsHello() {
        try {
            while (true){
                String result = restTemplate.getForObject("http://localhost:8081/user/hello", String.class);
                System.out.println("writeQps#result:" + result);
                Thread.sleep(500);
                System.out.println("-------------------------------------");
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
